#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# this lesson is based on python 3
'''
package is a way to organize modules. every package must has a __init__.py (empty or not)

mycompany
├─ __init__.py
├─ abc.py
└─ xyz.py

to call abc.py above, we first import mycompany, then call mycompany.abc

mycompany
 ├─ web
 │  ├─ __init__.py
 │  ├─ utils.py
 │  └─ www.py
 ├─ __init__.py
 ├─ abc.py
 └─ utils.py

 multilayer package is acceptable.
'''
# ====USING MODULE==== 

# first, let's write a module using build-in modules.

' a test module ' # the first string in a module py file is seemed as the annotation of the module

__author__ = 'Michael Liao' # use __author__ variable to sign your id

import sys

def test():
    args = sys.argv # this variable is a list containing all command line arguments
    if len(args)==1: # the list at least has one item, the now running script
        print('Hello, world!')
    elif len(args)==2:
        print('Hello, %s!' % args[1])
    else:
        print('Too many arguments!')

if __name__=='__main__': # only when the module is directly runned in command line, the condition will be True
    test()

def _private(): # _xx and __xx is private func and var name in module, which should not be used outside module
    __private = 'string'
    pass

# name like __xx__ is special func/var, which should not be used when we name our own func/var

# ====THIRD PARTY MODULE==== 

'''
use cmd to enter:
pip install xxx 
to install xxx package.

imported packages has to be in the current path, sys.path or PYTHONPATH
'''



